#include <stdio.h> //for printf
#include <stdlib.h> //for exit
#include <string.h>
#include "stack.h"

int main() {
    stack_t stackA;
    char *express = "984*+93/-"; 
    
    if (init(&stackA, 100) == STACK_FAIL) {
        printf("initial stack error\n");
        exit(1);
    }


    int x,y;
    for(int i=0; i < strlen(express); i++) {
        switch(express[i]) {
            case '+':
                pop(&stackA, &y);
                pop(&stackA, &x);
                push(&stackA, x+y);
                break; 
            case '-': 
                pop(&stackA, &y);
                pop(&stackA, &x);
                push(&stackA, x-y);
                break; 
            case '*': 
                pop(&stackA, &y);
                pop(&stackA, &x);
                push(&stackA, x*y);
                break; 
            case '/': 
                pop(&stackA, &y);
                pop(&stackA, &x);
                push(&stackA, x/y);
                break; 
            default:
                push(&stackA, express[i]-'0');
        }
    }
    pop(&stackA, &x);
    printf("result = %d\n", x);             
    return 0; 
}